toggle in css

39

var clicked = false;

function toggleBtnClick() {
  var img = document.getElementById('baseImg');
  if (clicked) {
    img.src = 'http://via.placeholder.com/350x150/e9e9e9/000000';
    clicked = false;
  } else {
    img.src = 'http://via.placeholder.com/350x150/3fafed/000000';
    clicked = true;
  }
}
.colors {
  toggle-root: colors [grape green blue red] at blue;
}

.colors button {
  toggle-trigger: colors;
}

/* for each color */
.colors button.grape {
  toggle-trigger: colors grape;
}

.show-colors:toggle(colors grape) {
  background-color: var(--grape-9);
}

Comments

Submit
0 Comments